<?php
namespace BigVideo\Other\Template;

abstract class RefreshBeverage
{
    protected $isAddCondiments=true;

    final public function prepareBeverageTemplate()
    {
        //第一步降水煮沸
        $this->boilWater();
        //第二步制作饮料
        $this->brew();
        //第三步将咖啡倒入杯中
        $this->pourInCup();
        if($this->isAddCondiments){
            //第四步加入调料
            $this->addCondiments();
        }
    }

    /**
     * 将水煮沸
     *
     */
    private function boilWater()
    {
        echo "煮沸水\n";
    }

    /**
     * 倒入杯中
     */
    private function pourInCup()
    {
        echo "倒入杯中\n";
    }

    /**
     * 制作饮料
     */
    abstract protected function brew();

    protected function isAddCondiments($isAddCondiments)
    {
        return $this->isAddCondiments = $isAddCondiments;
    }

    /**
     * 加入调料
     * @return mixed
     */
    abstract protected function addCondiments();
}